<?php
/**
 * GenerateRandom Action Helper
 *
 * @desc Envio de email
 * @uses Zend_Controller_Action_Helper
 */
class My_Controller_Action_Helper_Mail
    extends Zend_Controller_Action_Helper_Abstract {

    public $pluginLoader;
    public $resultado;

    public function __construct() {
        $this->pluginLoader = new Zend_Loader_PluginLoader ();
    }
 
    public function Mail($BodyHtml, $Subject, $addTo)
    {
        $authDetails = array(
            'port'=>25,
            'auth'=>'login',
            'username'=>'anp.net',
            'password'=>'anp.net.dpf'
        );
        $transport = new Zend_Mail_Transport_Smtp('mail.dpf.gov.br', $authDetails);
        Zend_Mail::setDefaultTransport($transport);

        $mail=new Zend_Mail('UTF-8');
        $mail->setFrom('anp.net@dpf.gov.br','ANP.net');
        $mail->setSubject($Subject);
        $mail->setBodyHtml($BodyHtml);
        $mail->addTo($addTo['email'],$addTo['nome']);
        try {
            $this->resultado = $mail->send();
        }catch(Exception $e) {
            Zend_Registry::get('Zend_Log')->log(print_r($e,true), Zend_Log::ERR);
        }
        
        return $this->resultado;
    }
 
    public function direct($BodyHtml, $Subject, $addTo)
    {
        return $this->Mail($BodyHtml, $Subject, $addTo);
    }
}